package com.cn.threeKindOfAnnotations.runtime;

import java.lang.reflect.Field;

public class Example {
    @RuntimeNote("This is a runtime annotation")
    private String someField;

    //@RuntimeNote 注解会在 .class 文件中保留，并且可以在运行时通过反射读取。在 main 方法中，我们使用反射读取注解的值并打印出来。
    public static void main(String[] args) throws NoSuchFieldException {
        Example example = new Example();
        Field field = example.getClass().getDeclaredField("someField");
        //获取并打印注解值
        if(field.isAnnotationPresent(RuntimeNote.class)){
            RuntimeNote note = field.getAnnotation(RuntimeNote.class);
            System.out.println("Annotation value: " + note.value());
        }
    }
}
